﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Leasson9 : MonoBehaviour
{
    private void OnGUI()
    {
        #region 知识一 GUILayout自动布局
        //主要用于进行编辑器开发 如果用它来做游戏UI不太适合
        GUI.BeginGroup(new Rect(20,20,200,300));
        //横向(默认纵向)
        GUILayout.BeginHorizontal();
        GUILayout.Button("11111");
        GUILayout.Button("22222222");
        GUILayout.Button("333333");
        GUILayout.EndHorizontal();
        //纵向
        GUILayout.BeginVertical();
        GUILayout.Button("4444");
        GUILayout.Button("555555");
        GUILayout.Button("6666");
        GUILayout.EndVertical();
        GUI.EndGroup();
        #endregion

        #region 知识二 布局选项
        ////控件的固定宽高
        //GUILayout.Width(300);
        //GUILayout.Height(200);

        ////允许控件的最小宽高
        //GUILayout.MinWidth(50);
        //GUILayout.MinHeight(50);

        ////允许控件的最大宽高
        //GUILayout.MaxWidth(100);
        //GUILayout.MaxHeight(100);

        ////允许或禁止水平拓展
        //GUILayout.ExpandWidth(true);
        //GUILayout.ExpandHeight(true);

        GUI.BeginGroup(new Rect(20, 100, 200, 300));
        //横向(默认纵向)
        GUILayout.Button("11111", GUILayout.Width(100));
        GUILayout.Button("22222222");
        GUILayout.Button("333333", GUILayout.ExpandWidth(false));
        GUILayout.Button("4444");
        GUILayout.Button("555555");
        GUILayout.Button("6", GUILayout.MaxWidth(30));
        GUI.EndGroup();
        #endregion
    }
}
